﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Text;

namespace HostingDomain3
{
    public partial class Domain : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

         protected void btnCheck_Click(object sender, EventArgs e)
        {
            string s = "";
            if (TabDomain.ActiveTabIndex == 0)
            {
                foreach (ListItem li in chkPhoBien.Items)
                {
                    if (li.Selected == true)
                    {
                        s += "|" + li.Text;
                        LoadDomain(txtDomain.Text, s.Substring(1));
                    }
                }
            }
            else if (TabDomain.ActiveTabIndex == 1)
            {
                foreach (ListItem li in chkVietNam.Items)
                {
                    if (li.Selected == true)
                    {
                        s += "|" + li.Text;
                        LoadDomain(txtDomain.Text, s.Substring(1));
                    }
                }
            }
            else if (TabDomain.ActiveTabIndex == 2)
            {
                foreach (ListItem li in chkQuocTe.Items)
                {
                    if (li.Selected == true)
                    {
                        s += "|" + li.Text;
                        LoadDomain(txtDomain.Text, s.Substring(1));
                    }
                }
            }
        }

        protected void LoadDomain(string Domain, string Ext)
        {
            int iCount = 0;
            string strCheck = "";
            string strToCheck = Domain;
            string strDomain = Ext;
            string[] strSplitEx = strDomain.Split(new char[] { '|' });
            StringBuilder strOut = new StringBuilder();

            strOut.Append("<b>Resuilt</b>");
            strOut.Append("<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"400\">");

            foreach (string strExt in strSplitEx)
            {
                strCheck = strToCheck + strExt;

                strOut.Append("     <tr>");
                strOut.Append("         <td width=\"250\" height=\"25\">");
                strOut.Append("             <span id=\"domain_").Append(iCount).Append("\">");
                strOut.Append(strCheck);
                strOut.Append("             </span>");
                strOut.Append("         </td>");
                strOut.Append("         <td width=\"150\">");
                strOut.Append("             <span id=\"check_").Append(iCount).Append("\"></span><br />");
                strOut.Append("             <script language=\"javascript\" type=\"text/javascript\">HostingDomain3('").Append(strToCheck).Append("','").Append(strExt).Append("','check_").Append(iCount).Append("');</script>");
                strOut.Append("         </td>");
                strOut.Append("     </tr>");

                iCount++;
            }
            strOut.Append("</table>");

            divResult.InnerHtml = strOut.ToString();
        }
    }
    }